﻿
Imports MySql.Data.MySqlClient
Imports System.Data.OleDb
Imports System.Data.Odbc
Imports System.Drawing
Imports System.Windows.Forms
Public Class packageoil
    Dim mysqlpass As String
    Dim ipconnect As String
    Dim usernamedb As String
    Dim dbname As String
    Dim health As String
    Dim mysql As MySqlConnection
    Public Sub New(ByRef mysql_pass As String, ByRef ip_connect As String, ByRef user_namedb As String, ByRef db_name As String, ByRef idhealthycare As String)
        InitializeComponent()
        mysqlpass = mysql_pass
        ipconnect = ip_connect
        usernamedb = user_namedb
        dbname = db_name
        health = idhealthycare
    End Sub
    Private Sub packageoil_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mysql = New MySqlConnection
        mysql.ConnectionString = "server=" + ipconnect + ";user id=" + usernamedb + ";password=" + mysqlpass + ";database=" + dbname + ";Character Set =utf8;"
        Try
            mysql.Open()
            '    MsgBox("CONNECTED TO DATABASE")
        Catch ex As Exception
            MsgBox("Can't Connect to database" + ex.Message)
            Me.Close()
        End Try
        Dim mySqlCommand As New MySqlCommand
        Dim mySqlAdaptor As New MySqlDataAdapter
        Dim mySqlReader As MySqlDataReader

        'mySqlCommand.CommandText = "SELECT DISTINCT * from Employee where dept_id in (SELECT dept_id from Department where dept_name like" + " '%" + TextBox1.Text + "%' )" + " or emp_name like " + "'%" + TextBox1.Text + "%'" + " or emp_surname like " + "'%" + TextBox1.Text + "%'" + " or emp_position like " + "'%" + TextBox1.Text + "%'" + " or emp_level like " + "'%" + TextBox1.Text + "%'" + ";"
        mySqlCommand.CommandText = "SELECT * FROM healthycare_ryh where idhealthycare = '" & health & "'"
        ' mySqlCommand.CommandText = 
        mySqlCommand.Connection = mysql
        mySqlAdaptor.SelectCommand = mySqlCommand

        Try
            mySqlReader = mySqlCommand.ExecuteReader



            While (mySqlReader.Read())
                'same all page
                txtsearch.Text = mySqlReader("p_id")
                txt_name.Text = mySqlReader("p_name")
                txt_sex.Text = mySqlReader("p_sex")
                txt_age.Text = mySqlReader("p_age")
                txt_tell.Text = mySqlReader("p_tell")
                txt_address.Text = mySqlReader("p_add")
                txt_aid.Text = mySqlReader("p_aid")
                txt_date.Text = mySqlReader("p_date")
                'tap1 package6
                tab1_txt_height.Text = mySqlReader("p_height")
                tab1_tab_weight.Text = mySqlReader("p_weight")
                tab1_txt_bmi.Text = mySqlReader("p_bmi")
                tab1_txt_pulserate.Text = mySqlReader("p_pulse")
                tab1_txt_bloodp.Text = mySqlReader("p_blood_pre")
                tab1_txt_eyer.Text = mySqlReader("p_eyeright")
                tab1_txt_eyel.Text = mySqlReader("p_eyeleft")
                'tab2 package6
                tab2_txt_groupblood.Text = mySqlReader("blo_gro")
                tab2_txt_rh.Text = mySqlReader("blo_rhe")
                tab2_txt_plate.Text = mySqlReader("blo_pla")
                tab2_txt_hb.Text = mySqlReader("blo_cbc_hb")
                tab2_txt_hct.Text = mySqlReader("blo_cbc_hct")
                tab2_txt_wbc.Text = mySqlReader("blo_cbc_wbc")
                tab2_txt_neutrophils.Text = mySqlReader("blo_cbc_n")
                tab2_txt_eosinophils.Text = mySqlReader("blo_cbc_e")
                tab2_txt_bashophils.Text = mySqlReader("blo_cbc_b")
                tab2_txt_lymphocytes.Text = mySqlReader("blo_cbc_l")
                tab2_txt_monocytes.Text = mySqlReader("blo_cbc_m")
                tab2_txt_atypical.Text = mySqlReader("blo_cbc_a")
                tab2_txt_redcell.Text = mySqlReader("blo_redcell")
                'tab3 package6
                tab3_txt_color.Text = mySqlReader("uri_col")
                tab3_txt_appearance.Text = mySqlReader("uri_app")
                tab3_txt_albumin.Text = mySqlReader("uri_alb")
                tab3_txt_glucose.Text = mySqlReader("uri_glu")
                tab3_txt_spgr.Text = mySqlReader("uri_spg")
                tab3_txt_blood.Text = mySqlReader("uri_blo")
                tab3_txt_ph.Text = mySqlReader("uri_ph")
                tab3_txt_rbc.Text = mySqlReader("uri_rbe")
                tab3_txt_wbc.Text = mySqlReader("uri_wbc")
                tab3_txt_epi.Text = mySqlReader("uri_epi")
                tab3_txt_other.Text = mySqlReader("uri_other")

                'tab4 package6
                tab4_result_phy.Text = mySqlReader("result_phy")
                tab4_result_x_ray.Text = mySqlReader("xray")
                tab3_txt_vdrl.Text = mySqlReader("vdrl")
                'tab4_result_us.Text = mySqlReader("result_us")
                tab4_result_ekg.Text = mySqlReader("phy_ekg")
                tab4_txt_fbs.Text = mySqlReader("che_fbs")
                tab3_txt_hiv.Text = mySqlReader("hiv")
                'tab5 packge6
                tab5_txt_bun.Text = mySqlReader("che_bun")
                tab5_txt_creatinine.Text = mySqlReader("che_cre")
                tab5_txt_uricacid.Text = mySqlReader("che_uri")
                tab5_txt_cholesterol.Text = mySqlReader("che_cho")
                tab5_txt_trigyceride.Text = mySqlReader("che_tri")
                tab5_txt_hdl.Text = mySqlReader("che_hdl")

                tab6_txt_ldl.Text = mySqlReader("che_ldl")
                tab6_txt_sgot.Text = mySqlReader("che_sgo")
                tab6_txt_sgpt.Text = mySqlReader("che_sgp")
                tab6_txt_alkaline.Text = mySqlReader("che_alk")
                tab6_txt_afp.Text = mySqlReader("che_afp")

                'tab6 package6
                txt_hbsag.Text = mySqlReader("vir_sag")
                txt_hbsab.Text = mySqlReader("vir_sab")
                txt_hbcab.Text = mySqlReader("vir_cab")
                txt_anti_igg.Text = mySqlReader("vir_igg")
                txt_hav_igm.Text = mySqlReader("vir_igm")
                TextBox5.Text = mySqlReader("che_cea")
                TextBox6.Text = mySqlReader("che_mer")
                tab6_stool_wbc.Text = mySqlReader("sto_wbc")
                tab6_stool_rbc.Text = mySqlReader("sto_rbc")
                tab6_stool_parasites.Text = mySqlReader("sto_ova")
                tab6_stool_blood.Text = mySqlReader("sto_occ")

                If mySqlReader("phy_eye") = "0" Then
                    r_eye1.Checked = True
                ElseIf mySqlReader("phy_eye") = "1" Then
                    r_eye2.Checked = True
                ElseIf mySqlReader("phy_eye") = "2" Then
                    r_eye3.Checked = True
                End If

                If mySqlReader("phy_nec") = "0" Then
                    neck1.Checked = True
                ElseIf mySqlReader("phy_nec") = "1" Then
                    neck2.Checked = True
                ElseIf mySqlReader("phy_nec") = "2" Then
                    neck3.Checked = True
                End If

                If mySqlReader("phy_hea") = "0" Then
                    heart1.Checked = True
                ElseIf mySqlReader("phy_hea") = "1" Then
                    heart2.Checked = True
                ElseIf mySqlReader("phy_hea") = "2" Then
                    heart3.Checked = True
                End If

                If mySqlReader("phy_vas") = "0" Then
                    vas1.Checked = True
                ElseIf mySqlReader("phy_vas") = "1" Then
                    vas2.Checked = True
                ElseIf mySqlReader("phy_vas") = "2" Then
                    vas3.Checked = True
                End If

                If mySqlReader("phy_lun_che") = "0" Then
                    chest1.Checked = True
                ElseIf mySqlReader("phy_lun_che") = "1" Then
                    chest2.Checked = True
                ElseIf mySqlReader("phy_lun_che") = "2" Then
                    chest3.Checked = True
                End If

                If mySqlReader("phy_abd") = "0" Then
                    ab1.Checked = True
                ElseIf mySqlReader("phy_abd") = "1" Then
                    ab2.Checked = True
                ElseIf mySqlReader("phy_abd") = "2" Then
                    ab3.Checked = True
                End If

                If mySqlReader("phy_lym") = "0" Then
                    lymp1.Checked = True
                ElseIf mySqlReader("phy_lym") = "1" Then
                    lymp2.Checked = True
                ElseIf mySqlReader("phy_kym") = "2" Then
                    lymp3.Checked = True
                End If

                If mySqlReader("phy_gus") = "0" Then
                    gu1.Checked = True
                ElseIf mySqlReader("phy_gus") = "1" Then
                    gu2.Checked = True
                ElseIf mySqlReader("phy_gus") = "2" Then
                    gu3.Checked = True
                End If

                If mySqlReader("phy_ext") = "0" Then
                    ex1.Checked = True
                ElseIf mySqlReader("phy_ext") = "1" Then
                    ex2.Checked = True
                ElseIf mySqlReader("phy_ext") = "2" Then
                    ex3.Checked = True
                End If

                If mySqlReader("phy_spi") = "0" Then
                    spine1.Checked = True
                ElseIf mySqlReader("phy_spi") = "1" Then
                    spine2.Checked = True
                ElseIf mySqlReader("phy_spi") = "2" Then
                    spine3.Checked = True
                End If

                If mySqlReader("phy_ski") = "0" Then
                    skin1.Checked = True
                ElseIf mySqlReader("phy_ski") = "1" Then
                    skin2.Checked = True
                ElseIf mySqlReader("phy_ski") = "2" Then
                    skin3.Checked = True
                End If

                If mySqlReader("phy_aud") = "0" Then
                    audio1.Checked = True
                ElseIf mySqlReader("phy_aud") = "1" Then
                    audio2.Checked = True
                ElseIf mySqlReader("phy_aud") = "2" Then
                    audio3.Checked = True
                End If

                If mySqlReader("phy_lun_tes") = "0" Then
                    lung1.Checked = True
                ElseIf mySqlReader("phy_lun_tes") = "1" Then
                    lung2.Checked = True
                ElseIf mySqlReader("phy_lun_tes") = "2" Then
                    lung3.Checked = True
                End If

                If mySqlReader("phy_ekg_oil") = "0" Then
                    ekg1.Checked = True
                ElseIf mySqlReader("phy_ekg_oil") = "1" Then
                    ekg2.Checked = True
                ElseIf mySqlReader("phy_ekg_oil") = "2" Then
                    ekg3.Checked = True
                End If
            End While
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        mysql.Close()

    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click

    End Sub
End Class